package com.xykj.enterprise.wechat.ext.service.contacts;

import com.xykj.enterprise.wechat.bean.ext.BaseResp;
import com.xykj.enterprise.wechat.bean.ext.contacts.department.CreateDepartmentVo;
import com.xykj.enterprise.wechat.bean.ext.contacts.department.DepartmentListVo;
import com.xykj.enterprise.wechat.ext.service.QYWXHttpCommUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
@Slf4j
public class ContactsDepartmentServiceImpl implements ContactsDepartmentService {

    @Override
    public CreateDepartmentVo createDepartment(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.postWithAccessToken("department/create", params, CreateDepartmentVo.class);
    }

    @Override
    public BaseResp deleteDepartment(String accessToken, Integer id) {
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        params.put("access_token", "");
        return QYWXHttpCommUtil.get("department/delete", params, BaseResp.class);
    }

    @Override
    public DepartmentListVo departmentList(String accessToken, Integer id) {
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.get("department/list", params, DepartmentListVo.class);
    }

    @Override
    public BaseResp updateDepartment(String accessToken, HashMap<String, Object> params) {
        params.put("access_token", accessToken);
        return QYWXHttpCommUtil.get("department/list", params, BaseResp.class);
    }
}
